package com.pdf.pdfserver.service.solr;

import com.pdf.pdfserver.vo.PageVO;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.data.domain.Pageable;

import java.io.IOException;
import java.util.List;

/**
 * @Author songfz
 * @Description
 * @Date 2022/1/10
 */
public interface SolrService<T> {

    /**
     * 关键字搜索
     *
     * @param key
     * @return
     */
    PageVO<T> search(String dbCore,String key, Pageable pageable) throws IOException, SolrServerException;

    /**
     * 单数据添加
     * @param dbCore 数据源名称
     * @param entity 数据
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    Boolean add(String dbCore, T entity) throws IOException, SolrServerException;

    /**
     * 批量数据添加
     * @param dbCore
     * @param list
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    boolean addList(String dbCore, List<T> list) throws IOException, SolrServerException;

    /**
     * id查询
     * @param dbCore
     * @param id
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    T getById(String dbCore,String id) throws IOException, SolrServerException;

    /**
     * 删除
     * @param dbCore
     * @param id
     * @return
     * @throws IOException
     * @throws SolrServerException
     */
    boolean deleteById(String dbCore, String id) throws IOException, SolrServerException;

    /**
     * 删除
     * @param dbCore
     * @param query
     * @return
     * @throws Exception
     */
    boolean deleteByString(String dbCore, String query) throws Exception;



}
